package flc.ast.activity;

import android.Manifest;
import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.databinding.ActivityTransferBinding;
import stark.common.basic.utils.StkPermissionHelper;

public class TransferActivity extends BaseAc<ActivityTransferBinding> {

    @Override
    protected int onCreate() {
        return R.layout.activity_transfer;
    }

    @Override
    protected void initView() {
        mDataBinding.ivTransferBack.setOnClickListener(v -> getOnBackPressedDispatcher().onBackPressed());

        mDataBinding.ivFileTransfer.setOnClickListener(this);
        mDataBinding.ivFileReceive.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        int id = v.getId();
        if (id == R.id.ivFileTransfer) {//文件传输
            getTransferPermission();
        } else if (id == R.id.ivFileReceive) {//文件接收
            getReceivePermission();
        }
    }

    @Override
    protected void initData() {

    }

    private void getTransferPermission() {
        StkPermissionHelper.permission(StkPermissionHelper.Permission.ACCESS_ALL_MEDIA)
                .reqPermissionDesc(getString(R.string.get_transfer_permission))
                .callback(new StkPermissionHelper.ACallback() {
                    @Override
                    public void onGranted() {
                        FileTransferActivity.type = 1;
                        startActivity(FileTransferActivity.class);
                    }
                }).request();
    }

    private void getReceivePermission() {
        StkPermissionHelper.permission(StkPermissionHelper.Permission.ACCESS_ALL_MEDIA, Manifest.permission.CAMERA)
                .reqPermissionDesc(getString(R.string.get_receive_permission))
                .callback(new StkPermissionHelper.ACallback() {
                    @Override
                    public void onGranted() {
                        startActivity(FileScanQrActivity.class);
                    }
                }).request();
    }

}